<!DOCTYPE html>
<html lang="cn">
<head>
    <meta charset="UTF-8">
    <title>查看新闻</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <script src="layui/layui.js"></script>
    <script src="js/jquery-1.9.1.min.js"></script>
</head>
<body>
<div class="layui-fluid">
    <form class="layui-form" style="margin: 10px" method="get" action="">
        <div class="layui-inline">
            <label class="layui-form-label">关键字</label>
            <div class="layui-input-inline" style="width: 200px;">
                <input type="text" name="keyWords" placeholder="请输入关键字" autocomplete="off" class="layui-input">
            </div>
            <div class="layui-input-inline" style="width: 100px;">
                <input type="submit" class="layui-btn" value="查询">
            </div>
        </div>
    </form>
    <table class="layui-table">
        <thead>
        <tr>
            <th>ID</th>
            <th>新闻标题</th>
            <th>新闻类别</th>
            <th>点击次数</th>
            <th>添加时间</th>
            <th>编辑</th>
            <th>删除</th>
        </tr>
        </thead>
        <?php foreach ($dataArr as $v) { ?>
        <tr>
            <td><?= $v['newsID'] ?></td>
            <td style="white-space: nowrap;overflow: hidden;text-overflow: ellipsis"><?= $v['newsTitle'] ?></td>
            <td><?= $v['cName'] ?></td>
            <td><?= $v['newsViews'] ?></td>
            <td><?= $v['newsDate'] ?></td>
            <td><a class="layui-btn layui-btn-sm" href="newsEdit.php?newsID=<?= $v['newsID'] ?>"><i
                    class="layui-icon layui-icon-edit"></i> 编辑</a></td>
            <td><a class="layui-btn layui-btn-sm layui-btn-danger del" href="newsDel.php?newsID=<?= $v['newsID'] ?>"><i
                    class="layui-icon layui-icon-delete"></i> 删除</a></td>
        </tr>
        <?php } ?>
    </table>
    <div style="text-align: center">
        <?=$pageHtml?>
    </div>
</div>
<script>
    layui.use('layer', function () {
        var layer = layui.layer;
        $('.del').on('click', function () {
            var url = $(this).attr('href');
            layer.confirm('确认删除吗', {icon: 3, title: '温馨提示'}, function (index) {
                location.href = url;
                layer.close(index);
            });
            return false;
        })
    });
    $(function () {
        $('#righttitle', window.parent.document).text($('title').text());
    });
</script>
</body>
</html>